#include "boot/Layout.h"

.code16
.text
// We start at 0x0:0x7c00.
.global _start
_start:
from_bios:
	movw $REAL_MODE_DS, %ax
	movw %ax, %ds
	movw %ax, %es
	movw $0x7c00, %di
	addw $ss_sp, %di
	lssw (%di), %sp

// Read 0 cylinder, 0 head, 2 sector, 8 sectors to es:bx.
	movw $0x80, %dx
	movw $0x0002, %cx
	movw $BOOTMAIN, %bx
	movw $0x0208, %ax
	int $0x13
	jc error

	movw $BOOTMAIN, %ax
	call *%ax

error:
	jmp error

ss_sp:
	.short REAL_MODE_SP, REAL_MODE_SS

// display route <([{
display_it:
	movb $0x3, %ah
	xorb %bh, %bh
	int $0x10
	movw $0x9, %cx
	movb $0x7, %bl
	movw $error_msg, %bp
	movw $0x1301, %ax
	int $0x10
	jmp error
error_msg:
	.ascii "\13\10Error ", __FILE__
	.byte __LINE__
// }])>

// Later data is set up by zero/script/deployOS.sh.
// .org 446
// 	// 16 * 4 hard disk partition table.
// .org 510
// 	// MBR valid flag.
// 	.byte 0x55, 0xaa

// vim: foldmarker=<([{,}])> foldmethod=marker
